import 'package:flutter/material.dart';
import 'package:flutter_changdian_football/pages/mine/contact_customer_service/contact_customer_service_controller.dart';
import 'package:flutter_changdian_football/widget/screenutil/custom_screenutil.dart';
import 'package:get/get.dart';

// 联系客服
class ContactCustomerServicePage extends StatelessWidget {
  const ContactCustomerServicePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xffF8FAF9),
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: const Color(0xffF8FAF9),
        elevation: 0,
        title: Text(
          '联系客服',
          style: TextStyle(fontSize: 16.sp, color: const Color(0xff333333)),
        ),
        iconTheme: const IconThemeData(
          color: Color(0xff333333)
        ),
      ),
      body: GetBuilder<ContactCustomerServiceController>(
        init: ContactCustomerServiceController(),
        builder: (contactCustomerServiceController) {
          return Container(
            width: double.infinity,
            decoration: const BoxDecoration(
              color: Color.fromRGBO(73, 147, 96, 1.0),
              image: DecorationImage(
                image: AssetImage('assets/images/lxkf_bj.png'),
                fit: BoxFit.cover
              )
            ),
            child: Column(
              children: [
                SizedBox(height: 60.w,),

                SizedBox(
                  width: 260.w,
                  child: Image.asset('assets/images/scan_add_kf.png'),
                ),

                SizedBox(height: 8.w,),

                SizedBox(
                  child: Text('周一至周日 10：00-18：00', style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w400, color: Colors.white),),
                ),

                SizedBox(height: 46.w,),

                Container(
                  margin: EdgeInsets.symmetric(horizontal: 35.sp),
                  width: double.infinity,
                  decoration: BoxDecoration(
                    color: Colors.white,
                    borderRadius: BorderRadius.circular(12.r),
                    boxShadow: [
                      BoxShadow(
                        color: Colors.grey.withOpacity(0.2), // 阴影颜色
                        spreadRadius: 2, // 阴影扩散范围
                        blurRadius: 3, // 阴影模糊程度
                        offset: const Offset(0, 2), // 阴影偏移量
                      ),
                    ]
                  ),
                  child: Column(
                    children: [
                      Container(
                        margin: EdgeInsets.only(top: 57.w, bottom: 20.w),
                        child: RepaintBoundary(
                          // key: _globalKey,
                          child: SizedBox(
                            width: 190.w, 
                            height: 190.w,
                            child: contactCustomerServiceController.protocolModel == null ? const SizedBox() : Image.network(contactCustomerServiceController.protocolModel?.url ?? ''),
                          ),
                        ),
                      ),

                      SizedBox(
                        child: Text('长按识别二维码添加客服微信', style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w400, color: const Color(0xff3D3D3D)),),
                      ),

                      SizedBox(height: 40.w,),

                      Container(
                        decoration: BoxDecoration(
                          border: Border(
                            top: BorderSide(
                              width: 1.w,
                              color: const Color(0xffDDDDDD)
                            )
                          )
                        ),
                        child: Row(
                          children: [
                            Expanded(
                              child: _buttonWidget(
                                text: '下载',
                                icon: 'assets/images/download_qr.png',
                                onTap: () {
                                  contactCustomerServiceController.saveNetworkImage();
                                }
                              ),
                            ),

                            Container(
                              width: 1.w,
                              height: 50.w,
                              color: const Color(0xffDDDDDD)
                            ),

                            Expanded(
                              child: _buttonWidget(
                                text: '分享',
                                icon: 'assets/images/share_qr.png',
                                onTap: () {
                                  contactCustomerServiceController.shareQrCode();
                                }
                              ),
                            ),
                          ],
                        ),
                      )
                    ],
                  ),
                )
              ],
            ),
          );
        }
      ),
    );
  }

  _buttonWidget({
    String text = '',
    String icon = '',
    Function? onTap
  }) {
    return GestureDetector(
      behavior: HitTestBehavior.translucent,
      onTap: () {
        onTap?.call();
      },
      child: Container(
        alignment: Alignment.center,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            SizedBox(
              width: 20.w,
              height: 20.w,
              child: Image.asset(icon),
            ),
            SizedBox(width: 6.w,),
            SizedBox(
              child: Text(text, style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w500, color: const Color(0xff3D3D3D)),),
            )
          ],
        ),
      ),
    );
  }

}